package com.gimi.cloud.bbp.manage.controller.prod;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.enums.ServiceNameConstants;
import com.gimi.cloud.bbp.common.utils.reqhead.Response;
import com.gimi.cloud.bbp.dto.prod.EcProdCatModelDTO;
import com.gimi.cloud.bbp.manage.service.prod.EcProdCatModelService;
import com.github.pagehelper.PageInfo;

/**
 * 品类模板Controller
 * @auther loongs
 * @date 2017/12/18  16:21
 */
@RestController
@RequestMapping(value = "prodCatModel")
public class ProdCatModelController {
    private static Logger logger = LoggerFactory.getLogger(ProdCatModelController.class);
    private EcProdCatModelService prodCatModelService;
    @Autowired
    public ProdCatModelController(EcProdCatModelService prodCatModelService) {
        this.prodCatModelService = prodCatModelService;
    }

   @RequestMapping(value = "/getProdCatModelList")
    public Response getProdCatModelList(@RequestBody EcProdCatModelDTO prodCatModelDTO, HttpServletResponse response) throws Exception{
        logger.info("获得商品品类模板列表，入参："+prodCatModelDTO);
        Response resp = new Response();
        List<EcProdCatModelDTO> prodCatModels = prodCatModelService.queryList(prodCatModelDTO,true);
        Map<String,Object> resData = new HashMap<>();
        resData.put(ServiceNameConstants.PAGEDATA_KEY,new PageInfo<>(prodCatModels));
        resp.setRes_data(resData);
        resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
        return resp;
    }
//    @RequestMapping(value = "/addProdCatModel")
//    public Response addProdCatModel(@RequestBody EcProdCatModelDTO prodCatModelDTO, HttpServletResponse response) {
//        logger.info("添加商品品类模板，入参："+prodCatModelDTO);
//        Response resp = new Response();
//        ResponseCodeEnum responseCodeEnum= prodCatModelService.addProdCatModel(prodCatModelDTO);
//        resp.setResponseCode(responseCodeEnum);
//        return resp;
//        Util.sendResponse(JsonUtil.toJson(resp), response);
//    }
//
//    @RequestMapping(value = "/gotoEditProdCatModel")
//    public Response gotoEditProdCatModel(@RequestBody EcProdCatModelDTO prodCatModelDTO, HttpServletResponse response) {
//        logger.info("转跳到商品品类模板编辑界面，入参："+prodCatModelDTO);
//        Response resp = new Response();
//        EcProdCatModelEntity prodCatModelEntity=prodCatModelService.gotoEditProdCatModel(prodCatModelDTO);
//        resp.setRes_data(prodCatModelEntity);
//        resp.setResponseCode(ResponseCodeEnum.SUCCESSED);
//        return resp;
//        Util.sendResponse(JsonUtil.toJSONStringWithDateFormatYYYYMMDDHHMMSS(resp),response);
//    }
//
//    @RequestMapping(value = "/editProdCatModel")
//    public Response editProdCatModel(@RequestBody EcProdCatModelDTO prodCatModelDTO, HttpServletResponse response) {
//        logger.info("编辑（修改）商品品类模板，入参："+prodCatModelDTO);
//        Response resp = new Response();
//        ResponseCodeEnum responseCodeEnum=prodCatModelService.editProdCatModel(prodCatModelDTO);
//        resp.setResponseCode(responseCodeEnum);
//        return resp;
//        Util.sendResponse(JsonUtil.toJson(resp), response);
//    }
//
//
//    @RequestMapping(value = "/deleteProdCatModel")
//    public Response deleteProdCatModel(@RequestBody EcProdCatModelDTO prodCatModelDTO, HttpServletResponse response) {
//        logger.info("删除商品品类模板，逻辑删除/启用，入参："+prodCatModelDTO);
//        Response resp = new Response();
//        ResponseCodeEnum responseCodeEnum=prodCatModelService.deleteProdCatModel(prodCatModelDTO);
//        resp.setResponseCode(responseCodeEnum);
//        return resp;
//        Util.sendResponse(JsonUtil.toJson(resp), response);
//    }
//
//    @RequestMapping(value = "/realDeleteProdCatModel")
//    public Response realDeleteProdCatModel(@RequestBody EcProdCatModelDTO prodCatModelDTO, HttpServletResponse response) {
//        logger.info("删除商品品类模板，入参："+prodCatModelDTO);
//        Response resp = new Response();
//        ResponseCodeEnum responseCodeEnum=prodCatModelService.realDeleteProdCatModel(prodCatModelDTO);
//        resp.setResponseCode(responseCodeEnum);
//        return resp;
//        Util.sendResponse(JsonUtil.toJson(resp), response);
//    }
}
